package com.sc.nft.entity.vo;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Date;

@Data
public class NoticeInfoVO {
    @ApiModelProperty("公告id")
    private Long id;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyTime;

    @ApiModelProperty("标题")
    private String noticeTitle;

    @ApiModelProperty("创作内容")
    private String noticeContent;

    @ApiModelProperty("开始时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date startTime;

    @ApiModelProperty("结束时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date endTime;

    @ApiModelProperty("状态 1 上架中 2下架中")
    private Integer noticeType;

    @ApiModelProperty("是否开启推送")
    private Boolean enablePush;

    public void setNoticeType(Integer noticeType) {
        // startTime和endTime的时间在范围内 则noticeType设置为1 否则为2
        DateTime now = DateTime.now();
        if (this.startTime.before(now)&& this.endTime.after(now)) {
            this.noticeType=1;
        }else{
            this.noticeType=2;
        }
    }
}
